<?php
get_header();
require(WEBTREATS_INCLUDES . "/var.php");

$portfolio_post = get_post_meta($post->ID, 'portfolio_full_img', true);
$portfolio_layout = get_post_meta($post->ID, 'portfolio_post_layout', true);

if($portfolio_post && !$portfolio_layout){
	return require(WEBTREATS_INCLUDES . "/template-portfolio-single.php");
}else{
?>

<div id="body_block" <?php webtreats_body_class(); ?>>
	
	<?php if($home_slider_page) { webtreats_header_slider_switcher($homepage_slider); } ?>

	<?php webtreats_teaser_text($post->ID); ?>

<div id="body_block_background">
	<div class="inner">

	<?php $breadcrumb_post_disable = get_post_meta($post->ID, 'breadcrumb_post_disable', true);
			if (!$breadcrumb_disable && !$breadcrumb_post_disable){ if (class_exists('simple_breadcrumb')) { $bc = new simple_breadcrumb; }} ?>

		<div id="main">
			<div class="content">


<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div class="post" id="post_id_<?php the_ID(); ?>">

<?php
$portfolio_full = get_post_meta($post->ID, 'portfolio_full_img', true);
$post_image = get_post_meta($post->ID, 'post_image', true);
$disable_post_image = get_post_meta($post->ID, 'disable_post_image', true);
?>

<?php if ( ($post_image && !$disable_post_image) && (!$portfolio_full) ) { webtreats_post_image(); } ?>


<h2 class="blog_header"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<div class="blog_meta">
	<?php $get_year = get_the_time('Y'); $get_month = get_the_time('m'); ?>
	Posted on: <a href="<?php echo get_month_link($get_year, $get_month); ?>"><?php the_time('m-j-Y') ?></a> 
	Posted in: <?php the_category(', ') ?>
</div>


<?php
$portfolio_fullsize = get_post_meta($post->ID, 'portfolio_post_fullsize', true);
$portfolio_video = get_post_meta($post->ID, 'portfolio_video_link', true);
$portfolio_full_resized = webtreats_image_resize($img_height=240, $img_width=568, $portfolio_full);
$portfolio_link = ($portfolio_video) ? $portfolio_video : $portfolio_full;
$rollover_class = ($portfolio_video) ? ' rollover_play' : ' rollover';
?>

<?php if ($portfolio_full && !$portfolio_fullsize) { ?>

	<div class="img_loader blog_post_image bg_hover">
		<a class="load_img" rel="lightbox" title="<?php the_title(); ?>" href="<?php echo $portfolio_link; ?>">
			<span class="rm_img noscript"><img class="framed fade_hover" src="<?php echo $portfolio_full_resized; ?>" height="<?php echo $img_height; ?>" width="<?php echo $img_width; ?>"  alt="" /></span>
		</a>
	</div>

<?php } ?>

	<div class="entry">
		<?php the_content(); ?>
		<div class="clearboth"></div>
	</div>
	<?php wp_link_pages('before=<div id="page-links">Pages: &after=</div>'); ?>
</div> <!-- post -->



<?php if (!$social_bookmarks) { ?>
	<a href="#" class="share_this_post"></a>
<?php } ?>


<?php if (!$about_author) { webtreats_author_info(); } ?>

<div class="clearboth"></div>

<?php if (!$related_popular_posts) { ?>
	<div id="popular_related_posts">	
		<div class="minimal_arrow_tab_set">
			<ul class="tabs">
				<li><a href="#">Popular Posts</a></li>
				<li><a href="#">Related Posts</a></li>
			</ul>
			<div class="tab_content"><?php webtreats_popular_post(); ?></div>
			<div class="tab_content"><?php webtreats_related_post(); ?></div>
		</div>	
	</div>	
<?php } ?>

<div id="comments">	
	<?php comments_template('', true); ?>
</div>

<?php endwhile; else : ?>
	<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>

<?php if($get_template == 'template-full.php') { echo '</div></div>'; }else{ get_sidebar(); } ?>

<?php get_footer(); ?>

<?php } ?>